<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
	date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
	$usuario = $_SESSION['name'];
	$fecha = date("Y-m-d H:i:s");
	$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Registro de personal' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}

$cedula = $_GET['cedula'];
if ($cedula){
	$sql = mysql_query("SELECT CI_p, Nombres, Apellidos, Sexo, date_format(F_nac, '%d - %m - %Y'), T_casa, T_movil, Direccion, date_format(F_ingreso, '%d - %m - %Y'), Titulo, Cargo FROM personal WHERE CI_p='$cedula'");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Personal</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css">
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css">
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css">
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/ValidarPersonal.js"></script>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
Validar();

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});

});
</script>
<!-- fin botones-->
<script type="text/javascript" src="js/prototype.js"></script>
<script>
function cargo(car){ 
	if(car=="Docente"){
		document.getElementById('obrero').style.display="none";
		document.getElementById('administrativo').style.display="none";
	}else if(car=="Obrero"){
		document.getElementById('obrero').style.display="inline";
		document.getElementById('administrativo').style.display="none";
	}else if(car=="Administrativo"){
		document.getElementById('administrativo').style.display="inline";
		document.getElementById('obrero').style.display="none";
	}else if(car==""){
		document.getElementById('administrativo').style.display="none";
		document.getElementById('obrero').style.display="none";
	}
}

<!--
var nav4 = window.Event ? true : false;
function acceptNum(evt){   
var key = nav4 ? evt.which : evt.keyCode;   
return (key <= 13 || (key>= 48 && key <= 57));
}
//-->
</script>
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>


</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<!-- Agregar la nacionalidad del select al campo input de la cedula -->
<script language="JavaScript1.2">
function verifyInput(_selList,_textBox) {
	document.getElementById('Cedula').readOnly = false;
	var SI = eval(_selList+".selectedIndex");
	var SV = eval(_selList+".options[SI].value");
	eval(_textBox+".value = SV");
	var a = eval(_selList+".options.selectedIndex=0");
	document.FormPersonal.Cedula.focus()
}

function comprobar_p()
{
  var url = 'http://sistemalamora.no-ip.org/sistema/sistema_escuela/comprobar_p.php';
  var pars= ('Cedula=' + document.getElementById('Cedula').value);
  var myAjax = new Ajax.Updater( 'comprobar_mensaje_p', url, { method: 'get', parameters: pars});
}

//pasar la cedula por la url
function Pasar() {
   var cedula=document.FormPersonal.Cedula.value;
   document.location='Personal.php?cedula='+cedula; 
}
</script>
<!-- fin Agregar la nacionalidad del select al campo input de la cedula -->
<form action="ResPersonal.php" method="POST" name="FormPersonal" id="FormPersonal">
<blockquote><h2 align="center">REGISTRO DE PERSONAL</h2></blockquote>
<label><font color=#FF0000>(*) Campos obligatorios</font></label>
		<fieldset>
			<legend align=left><b><font size=2>DATOS PERSONALES</font></b></legend>
			<table width=100% cellspacing=5 cellpadding=3 border=0>
				
				<?php if($sql){
				while($row=mysql_fetch_array($sql)){
					echo "
				<tr>
					<td width=50%><label style='color: #FF0000'>*</label> C&eacute;dula de Identidad: </td><td><input readonly type=text value='$row[0]' name='Cedula'><label> Ej: V-12345678</label>&nbsp;<span id='comprobar_mensaje_p'></span></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Nombres: </td><td><input type=text name='Nombres' id='Nombres' value='$row[1]' maxLength=25><label> Ej: Carlos Luis</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Apellidos: </td><td><input type=text name='Apellidos' id='Apellidos' value='$row[2]' maxLength=25><label> Ej: P&eacute;rez Tovar</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Sexo: </td><td><select name='Sexo' id='Sexo'><option></option>
										<option "; if ($row[3]=='Masculino'){ echo "Selected"; } echo ">Masculino</option>
										<option "; if ($row[3]=='Femenino'){ echo "Selected"; } echo ">Femenino</option></select></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Fecha Nac. </td><td><input readonly value='$row[4]' type=text id='calendar-inputField' name='F_nac' maxLength=14><img src='images/calendar.gif' id='calendar-trigger' align=top><label> Ej: 3 - 04 - 1991</label>
						<script>
							Calendar.setup({
								trigger    : 'calendar-trigger',
								inputField : 'calendar-inputField',
								dateFormat	 : '%e - %m - %Y',
								onSelect   : function() { this.hide() }
							});
						</script></td>
				</tr>
				<tr>";
					$tlf = explode('-',$row[5]);
				echo "<td>Tel&eacute;fono Casa: </td><td><select name='T_casa' id='T_casa'><option></option>
																<option "; if ($tlf[0]=='0240'){ echo "Selected"; } echo ">0240</option>
																<option "; if ($tlf[0]=='0241'){ echo "Selected"; } echo ">0241</option>
																<option "; if ($tlf[0]=='0242'){ echo "Selected"; } echo ">0242</option>
																<option "; if ($tlf[0]=='0243'){ echo "Selected"; } echo ">0243</option>
																<option "; if ($tlf[0]=='0244'){ echo "Selected"; } echo ">0244</option>
																<option "; if ($tlf[0]=='0412'){ echo "Selected"; } echo ">0412</option>
																<option "; if ($tlf[0]=='0414'){ echo "Selected"; } echo ">0414</option>
																<option "; if ($tlf[0]=='0424'){ echo "Selected"; } echo ">0424</option>
																<option "; if ($tlf[0]=='0416'){ echo "Selected"; } echo ">0416</option>
																<option "; if ($tlf[0]=='0426'){ echo "Selected"; } echo ">0426</option></select>
					<input type=text name='T_casa2' size=9 maxLength=7 value='$tlf[1]' onKeyPress=\"return acceptNum(event)\"><label> Ej: 1234567</label></td>
				</tr>
				<tr>";
					$tlf2 = explode('-',$row[6]);
				echo "<td>Tel&eacute;fono M&oacute;vil: </td><td><select name='T_movil' id='T_movil'><option></option>
																<option "; if ($tlf2[0]=='0412'){ echo "Selected"; } echo ">0412</option>
																<option "; if ($tlf2[0]=='0414'){ echo "Selected"; } echo ">0414</option>
																<option "; if ($tlf2[0]=='0424'){ echo "Selected"; } echo ">0424</option>
																<option "; if ($tlf2[0]=='0416'){ echo "Selected"; } echo ">0416</option>
																<option "; if ($tlf2[0]=='0426'){ echo "Selected"; } echo ">0426</option></select>
					<input type=text name='T_movil2' size=9 maxLength=7 value='$tlf2[1]' onKeyPress=\"return acceptNum(event)\"><label> Ej: 1234567</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Direcci&oacute;n: </td><td><input type=text name='Direccion' id='Direccion' value='$row[7]' size=40 maxLength=50><br><label> Ej: Calle sur, sector B casa nro 14</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Fecha de Ingreso: </td><td><input readonly type=text id='calendar-inputField2' value='$row[8]' name='F_ingreso' maxLength=14><img src='images/calendar.gif' id='calendar-trigger2' align=top><label> Ej: 3 - 04 - 1991</label>
					<script>
							Calendar.setup({
								trigger    : 'calendar-trigger2',
								inputField : 'calendar-inputField2',
								dateFormat	 : '%e - %m - %Y',
								onSelect   : function() { this.hide() }
							});
						</script></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> T&iacute;tulo: </td><td><input type=text name='Titulo' id='Titulo' value='$row[9]' maxLength=50><br><label> Ej: Lic. en Educacion Primaria</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Tipo de Personal: </td><td><input tipe=text name='Cargo' id='Cargo' value='$row[10]' readonly></td>
				</tr>
				";
				}
				} else if(!$sql) {
					echo "
				<tr>
					<td width=50%><label style='color: #FF0000'>*</label> C&eacute;dula de Identidad: </td><td><select name='Nac' id='Nac' onchange=\"verifyInput('document.FormPersonal.Nac','document.FormPersonal.Cedula')\"><option></option><option>V-</option><option>E-</option></select><input readonly type=text name='Cedula' id='Cedula' size=8 maxLength=10 onKeyUp='comprobar_p(this.value)' onKeyPress='return acceptNum(event)'><a href='#' onclick='Pasar();'><img src='images/lupa.jpg' width=20 height=20 align=top></a><label> Ej: V-12345678</label>&nbsp;<span id='comprobar_mensaje_p'></span></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Nombres: </td><td><input type=text name='Nombres' id='Nombres' maxLength=25><label> Ej: Carlos Luis</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Apellidos: </td><td><input type=text name='Apellidos' id='Apellidos' maxLength=25><label> Ej: P&eacute;rez Tovar</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Sexo: </td><td><select name='Sexo' id='Sexo'><option></option><option>Masculino</option><option>Femenino</option></select></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Fecha Nac. </td><td><input readonly type=text id='calendar-inputField' name='F_nac' maxLength=14><img src='images/calendar.gif' id='calendar-trigger' align=top><label> Ej: 3 - 04 - 1991</label>
						<script>
							Calendar.setup({
								trigger    : 'calendar-trigger',
								inputField : 'calendar-inputField',
								dateFormat	 : '%e - %m - %Y',
								onSelect   : function() { this.hide() }
							});
						</script></td>
				</tr>
				<tr>
					<td>Tel&eacute;fono Casa: </td><td><select name='T_casa' id='T_casa'><option></option>
																<option>0240</option>
																<option>0241</option>
																<option>0242</option>
																<option>0243</option>
																<option>0244</option>
																<option>0412</option>
																<option>0414</option>
																<option>0424</option>
																<option>0416</option>
																<option>0426</option></select>
					<input type=text name='T_casa2' size=9 maxLength=7 onKeyPress=\"return acceptNum(event)\"><label> Ej: 1234567</label></td>
				</tr>
				<tr>
					<td>Tel&eacute;fono M&oacute;vil: </td><td><select name='T_movil' id='T_movil'><option></option>
																<option>0412</option>
																<option>0414</option>
																<option>0424</option>
																<option>0416</option>
																<option>0426</option></select>
					<input type=text name='T_movil2' size=9 maxLength=7 onKeyPress=\"return acceptNum(event)\"><label> Ej: 1234567</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Direcci&oacute;n: </td><td><input type=text name='Direccion' id='Direccion' size=40 maxLength=50><br><label> Ej: Calle sur, sector B casa nro 14</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Fecha de Ingreso: </td><td><input readonly type=text id='calendar-inputField2' name='F_ingreso' maxLength=14><img src='images/calendar.gif' id='calendar-trigger2' align=top><label> Ej: 3 - 04 - 1991</label>
					<script>
							Calendar.setup({
								trigger    : 'calendar-trigger2',
								inputField : 'calendar-inputField2',
								dateFormat	 : '%e - %m - %Y',
								onSelect   : function() { this.hide() }
							});
						</script></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> T&iacute;tulo: </td><td><input type=text name='Titulo' id='Titulo' maxLength=50><br><label> Ej: Lic. en Educacion Primaria</label></td>
				</tr>
				<tr>
					<td><label style='color: #FF0000'>*</label> Tipo de Personal: </td><td><select name='Cargo' id='Cargo' onChange=\"cargo(this.value)\"><option></option>
												<option value=Docente>Docente</option>
												<option value=Obrero>Obrero</option>
												<option value=Administrativo>Administrativo</option></select></td>
				</tr>";
				 } ?>
				</table>
				
				<div id="obrero" style="display: none;">
					<table width=100% cellspacing=5 cellpadding=3 border=0>
						<tr>
							<td width=50%>* Cargo: </td><td><select name="Cargo_o"><option></option>
																	<option>Aseador(a)</option>
																	<option>Portero(a)</option>
																	<option>Superv. Mtto</option>
																	<option>Jardinero(a)</option></select></td>
						</tr>
						<tr>
							<td>* Turno: </td><td><select name="Turno"><option></option>
														<option>Ma&ntilde;ana</option>
														<option>Tarde</option></select></td>
						</tr>
					</table>
				</div>
				<div id="administrativo" style="display: none;">
					<table width=100% cellspacing=5 cellpadding=3 border=0>
						<tr>
							<td width=50%>* Cargo: </td><td><select name="Cargo_a"><option></option>
																	<option>Director(a)</option>
																	<option>Sub-director(a) Acad.</option>
																	<option>Sub-director(a) Admin.</option>
																	<option>Secretaria</option>
																	<option>Bibliotecaria</option></select></td>
						</tr>
						<input type=hidden name='Periodo' id='Periodo' value='<?php if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; echo "$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; echo "$anio - $anio2"; } ?>'>
					</table>
				</div>
			</fieldset>

<div class="post">
<span></span></div>

<div name="botonera" align=center>
	<input class=button type=Submit value=Guardar> <input class=button type=button value=Cancelar onClick="location='index.php'">
</div>
</form>

<div align=right><a title='Ayuda' href="Manuales/ManualUsuario_2.3.pdf" onclick="window.open(this.href,'Manual','params'); return false"><img src='images/help.png' width=8% height=15%></a></div>

</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
